package 作业._p114实训1三;

import java.util.Scanner;

class Triangle extends Shape {
    double a,b,c;
    public Triangle() {
    }
    public Triangle(String name) {
        super(name);
    }

    public void input(){
        Scanner sc = new Scanner(System.in);
        System.out.println("请输入三角形三边长：");
        a = sc.nextDouble();b = sc.nextDouble();c = sc.nextDouble();
        if (a+b>c && a+c>b && c+b>a){

        }else {
            System.out.println("边长不能构成三角形，请重新输入：");
            input();
        }
    }

    @Override
    public void Area() {
        input();
        double p = (a+b+c)/2;
        double S = Math.sqrt(p*(p-a)*(p-b)*(p-c));//海伦公式
        System.out.println("三角形面积为："+S);
    }
}
